package lab02.test23;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

/**
 * Created by Administrator on 2017/11/2.
 */
public class Test2 {
    public static void main(String[] args) throws ParseException {
        //1输入生日
        System.out.println("请输入你的生日：");
        Scanner scanner = new Scanner(System.in);
        String birthday,now;
        birthday = scanner.nextLine();
        System.out.println("请输入现在的日期：");
        now=scanner.nextLine();
        //2生日还有几天
        /*
        * SimpleDateFormat
        * Calendar  日历
        *
        */
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-mm-dd");
        Calendar calendar=Calendar.getInstance();

        long time1=0;
        long time2=0;

        calendar.setTime(simpleDateFormat.parse(birthday));
        //time1=calendar.get(Calendar.DAY_OF_YEAR);
        time1=calendar.getTimeInMillis();

        calendar.setTime(simpleDateFormat.parse(now));
        // time2=calendar.get(Calendar.DAY_OF_YEAR);
        time2=calendar.getTimeInMillis();
        System.out.println("相差的天数为："+(time1-time2)/(24*60*60*1000));
        //跨月不可以

    }
}
